<?php

include_once '../../Core/Conexion.php';
include_once '../../Core/ControladorSet.php';
include_once '../../Core/InterfazDatos.php';
///****
include_once '../entidades/Categoria.php';
include_once '../entidades/Materia.php';

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of lista
 *
 * @author cHr15t14n
 */
class lista extends ControladorSet {

    public function buscarValores() {
      $cadena="";
      $entidad=new Materia("","","","");
      $consulta=$this->conexion->consultaTabla($entidad);
      $fila=  mysql_fetch_array($consulta);
      do
      {
          $cadena=$cadena."<tr>";          
          $cadena=$cadena."<td>".$fila[2]."</td>";  
           $consulta2=$this->conexion->consultaTabla(new Categoria($fila[1],"",""));
           
            if(mysql_num_rows($consulta2)>0)
            {
                $fila2=  mysql_fetch_array($consulta2);
                $cadena=$cadena."<td>".$fila2[1]."</td>";   
            }
            else
            {
                $cadena=$cadena."<td>Sin asignar</td>";   
            }
          $cadena=$cadena."<td>".$fila[3]."</td>"; 
          $cadena = $cadena . "<td>" . "<a href=editar.php?codigo=" . $fila[0] . " >edit<a>" . "</td>";
          $cadena = $cadena . "<td>" . "<a onclick='return confirm(\"Seguro que desea eliminar estos datos?\");' href=php/Eliminar.php?codigo=" . $fila[0] . " >elimr<a>" . "</td>";
          
          $cadena=$cadena."</tr>";          
      }while($fila=  mysql_fetch_array($consulta));
              
      $this->diccionario['tabla'] = $cadena;
      
    }

    public function setDiccionario() {
        $this->diccionario = array(
            "tabla" => "vacio",
        );
    }

    public function setValorSesion() {
        $this->valorSesion = array("admin", "", "");
    }

//put your code here
}

$controlador = new lista('listaVista.php');
$controlador->rederizarPagina();
